//
//  HeartControl.m
//  FreeTime
//
//  Created by  on 16/8/26.
//  Copyright © 2016年 SRDZ.com. All rights reserved.
//

#import "HeartControl.h"
#import "Header.h"
#import "HeartCell.h"
@interface HeartControl (){
    UIButton * tempBtn;

}

@end

@implementation HeartControl
- (void)viewWillAppear:(BOOL)animated{
//    self.navigationController.navigationBarHidden = NO;
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;

}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNav];
    [self setupUI];
}

#pragma mark -- setupUI --
- (void)setupUI{
    NSArray * titleArr = @[@"我对TA的心动",@"TA对我的心动"];
    for (int i  =0; i<2; i++) {
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(WindowWidth/2*i, 0, WindowWidth/2, 45);
        [btn setTitle:titleArr[i] forState:UIControlStateNormal];
        [btn setTitleColor:HOME_COLOR forState:UIControlStateNormal];
        if (i==1) {
            [btn setTitleColor:[ImageUtil colorWithRgb:0x999999] forState:UIControlStateNormal];
            [ToolUtil createVerticalLine:12.5 superView:btn lift:0 height:20 color:[ImageUtil colorWithRgb:0xe6e6e6]];
        }else{
            tempBtn=btn;
        }
        btn.tag = 100+i;
        [btn addTarget:self action:@selector(heartClick:) forControlEvents:UIControlEventTouchUpInside];
        btn.titleLabel.font = FONT(13);
        
        [self.view addSubview:btn];
        
    }
    CGFloat y1 = [ToolUtil createLine:44 superView:self.view lift:10 width:WindowWidth-20 hight:1 color:[ImageUtil colorWithRgb:0xe6e6e6]];
    self.tableView.frame = CGRectMake(0, y1, WindowWidth, WindowHeight-y1);
    [self.tableView registerClass:[HeartCell class] forCellReuseIdentifier:@"HeartCell"];
    
}
#pragma mark tableViewMethord
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 78;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * cellIdentifier = @"HeartCell";
    HeartCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

#pragma mark -- button响应事件 --
- (void)heartClick:(UIButton *)btn{
//    button=btn;
    [tempBtn setTitleColor:[ImageUtil colorWithRgb:0x999999] forState:UIControlStateNormal];

    if (btn.tag==100) {
        [btn setTitleColor:HOME_COLOR forState:UIControlStateNormal];

    }else{
        
        [btn setTitleColor:HOME_COLOR forState:UIControlStateNormal];

    }
    tempBtn=btn;
}

@end
